home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / POV-Ray 3.0.2 / src / SOURCE / POVRAY.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-15  |  11.2 KB  |  426 lines  |  [TEXT/CWIE]

  1. /****************************************************************************
  2. *                   povray.h
  3. *
  4. *  This module contains all defines, typedefs, and prototypes for POVRAY.C.
  5. *
  6. *  from Persistence of Vision(tm) Ray Tracer
  7. *  Copyright 1996 Persistence of Vision Team
  8. *---------------------------------------------------------------------------
  9. *  NOTICE: This source code file is provided so that users may experiment
  10. *  with enhancements to POV-Ray and to port the software to platforms other
  11. *  than those supported by the POV-Ray Team.  There are strict rules under
  12. *  which you are permitted to use this file.  The rules are in the file
  13. *  named POVLEGAL.DOC which should be distributed with this file. If
  14. *  POVLEGAL.DOC is not available or for more info please contact the POV-Ray
  15. *  Team Coordinator by leaving a message in CompuServe's Graphics Developer's
  16. *  Forum.  The latest version of POV-Ray may be found there as well.
  17. *
  18. * This program is based on the popular DKB raytracer version 2.12.
  19. * DKBTrace was originally written by David K. Buck.
  20. * DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
  21. *
  22. *****************************************************************************/
  23.  
  24.  
  25. #ifndef POVRAY_H
  26. #define POVRAY_H
  27.  
  28. #include <time.h>
  29.  
  30. #include "atmosph.h"
  31. #include "camera.h"
  32. #include "point.h"
  33. #include "render.h"
  34.  
  35.  
  36. /*****************************************************************************
  37. * Global preprocessor defines
  38. ******************************************************************************/
  39.  
  40. #define MAX_LIBRARIES 25
  41.  
  42. #define STAGE_STARTUP         0  /* set in POVRAY.C */
  43. #define STAGE_BANNER          1  /* set in POVRAY.C */
  44. #define STAGE_INIT            2  /* set in POVRAY.C */
  45. #define STAGE_ENVIRONMENT     3  /* set in POVRAY.C */
  46. #define STAGE_COMMAND_LINE    4  /* set in POVRAY.C */
  47. #define STAGE_FILE_INIT       5  /* set in POVRAY.C */
  48. #define STAGE_PARSING         7  /* set in PARSE.C */
  49. #define STAGE_CONTINUING      8  /* set in POVRAY.C */
  50. #define STAGE_RENDERING       9  /* set in POVRAY.C */
  51. #define STAGE_SHUTDOWN       10  /* set in POVRAY.C */
  52. #define STAGE_INI_FILE       11  /* set in POVRAY.C */
  53. #define STAGE_CLEANUP_PARSE  12  /* set in PARSE.C */
  54. #define STAGE_SLAB_BUILDING  13  /* set in POVRAY.C */
  55. #define STAGE_TOKEN_INIT     14  /* set in TOKENIZE.C */
  56. #define STAGE_INCLUDE_ERR    15  /* set in TOKENIZE.C */
  57. #define STAGE_FOUND_INSTEAD  16  /* set in TOKENIZE.C */
  58.  
  59. #define DISPLAY           0x000001L
  60. #define VERBOSE           0x000002L
  61. #define DISKWRITE         0x000004L
  62. #define PROMPTEXIT        0x000008L
  63. #define ANTIALIAS         0x000010L
  64. #define RGBSEPARATE       0x000020L
  65. #define EXITENABLE        0x000040L
  66. #define CONTINUE_TRACE    0x000080L
  67. #define BUFFERED_OUTPUT   0x000100L
  68. #define JITTER            0x000200L
  69. #define PREVIEW           0x000400L
  70. #define SPLIT_UNION       0x000800L
  71. #define USE_VISTA_BUFFER  0x001000L
  72. #define USE_LIGHT_BUFFER  0x002000L
  73. #define USE_VISTA_DRAW    0x004000L
  74. #define REMOVE_BOUNDS     0x008000L
  75. #define CYCLIC_ANIMATION  0x010000L
  76. #define OUTPUT_ALPHA      0x020000L
  77. #define HF_GRAY_16        0x040000L
  78. #define GAMMA_CORRECT     0x080000L
  79. #define RADIOSITY         0x100000L
  80. #define FROM_STDIN        0x200000L
  81. #define TO_STDOUT         0x400000L
  82.  
  83. #define Q_FULL_AMBIENT 0x000001L
  84. #define Q_QUICKC       0x000002L
  85. #define Q_SHADOW       0x000004L
  86. #define Q_AREA_LIGHT   0x000008L
  87. #define Q_REFRACT      0x000010L
  88. #define Q_REFLECT      0x000020L
  89. #define Q_NORMAL       0x000040L
  90. #define Q_VOLUME       0x000080L
  91.  
  92. #define EF_RADIOS  1
  93. #define EF_HALOS   2
  94. #define EF_ATMOS   4
  95.  
  96. #define QUALITY_0  Q_QUICKC+Q_FULL_AMBIENT
  97. #define QUALITY_1  QUALITY_0
  98. #define QUALITY_2  QUALITY_1-Q_FULL_AMBIENT
  99. #define QUALITY_3  QUALITY_2
  100. #define QUALITY_4  QUALITY_3+Q_SHADOW
  101. #define QUALITY_5  QUALITY_4+Q_AREA_LIGHT
  102. #define QUALITY_6  QUALITY_5-Q_QUICKC+Q_REFRACT
  103. #define QUALITY_7  QUALITY_6
  104. #define QUALITY_8  QUALITY_7+Q_REFLECT+Q_NORMAL
  105. #define QUALITY_9  QUALITY_8+Q_VOLUME
  106.  
  107.  
  108. /*****************************************************************************
  109. * Global typedefs
  110. ******************************************************************************/
  111.  
  112. typedef struct Frame_Struct FRAME;
  113.  
  114. struct Frame_Struct
  115. {
  116.   CAMERA *Camera;
  117.   int Screen_Height, Screen_Width; /* OPTIONS */
  118.   int Number_Of_Light_Sources;
  119.   LIGHT_SOURCE *Light_Sources;
  120.   OBJECT *Objects;
  121.   DBL Atmosphere_IOR, Antialias_Threshold;
  122.   COLOUR Background_Colour;
  123.   COLOUR Ambient_Light;
  124.   COLOUR Irid_Wavelengths;
  125.   ATMOSPHERE *Atmosphere;
  126.   FOG *Fog;
  127.   RAINBOW *Rainbow;
  128.   SKYSPHERE *Skysphere;
  129. };
  130.  
  131. typedef enum STATS
  132. {
  133.   /* Computations are performed on these three */
  134.   Number_Of_Pixels = 0,
  135.   Number_Of_Pixels_Supersampled,
  136.   Number_Of_Samples,
  137.   Number_Of_Rays,
  138.   Calls_To_DNoise,
  139.   Calls_To_Noise,
  140.   ADC_Saves,
  141.  
  142.   /* objects */
  143.   Bounding_Region_Tests,
  144.   Bounding_Region_Tests_Succeeded,
  145.   Clipping_Region_Tests,
  146.   Clipping_Region_Tests_Succeeded,
  147.   Istack_overflows,
  148.  
  149.   Ray_Bicubic_Tests,
  150.   Ray_Bicubic_Tests_Succeeded,
  151.   Ray_Blob_Tests,
  152.   Ray_Blob_Tests_Succeeded,
  153.   Blob_Element_Tests,
  154.   Blob_Element_Tests_Succeeded,
  155.   Blob_Bound_Tests,
  156.   Blob_Bound_Tests_Succeeded,
  157.   Ray_Box_Tests,
  158.   Ray_Box_Tests_Succeeded,
  159.   Ray_Cone_Tests,
  160.   Ray_Cone_Tests_Succeeded,
  161.   Ray_Disc_Tests,
  162.   Ray_Disc_Tests_Succeeded,
  163.   Ray_HField_Tests,
  164.   Ray_HField_Tests_Succeeded,
  165.   Ray_HField_Box_Tests,
  166.   Ray_HField_Box_Tests_Succeeded,
  167.   Ray_HField_Triangle_Tests,
  168.   Ray_HField_Triangle_Tests_Succeeded,
  169.   Ray_HField_Block_Tests,
  170.   Ray_HField_Block_Tests_Succeeded,
  171.   Ray_HField_Cell_Tests,
  172.   Ray_HField_Cell_Tests_Succeeded,
  173.   Ray_Fractal_Tests,
  174.   Ray_Fractal_Tests_Succeeded,
  175.   Ray_Lathe_Tests,
  176.   Ray_Lathe_Tests_Succeeded,
  177.   Lathe_Bound_Tests,
  178.   Lathe_Bound_Tests_Succeeded,
  179.   Ray_Mesh_Tests,
  180.   Ray_Mesh_Tests_Succeeded,
  181.   Ray_Plane_Tests,
  182.   Ray_Plane_Tests_Succeeded,
  183.   Ray_Poly_Tests,
  184.   Ray_Poly_Tests_Succeeded,
  185.   Ray_Polygon_Tests,
  186.   Ray_Polygon_Tests_Succeeded,
  187.   Ray_Prism_Tests,
  188.   Ray_Prism_Tests_Succeeded,
  189.   Prism_Bound_Tests,
  190.   Prism_Bound_Tests_Succeeded,
  191.   Ray_Quadric_Tests,
  192.   Ray_Quadric_Tests_Succeeded,
  193.   Ray_Sor_Tests,
  194.   Ray_Sor_Tests_Succeeded,
  195.   Sor_Bound_Tests,
  196.   Sor_Bound_Tests_Succeeded,
  197.   Ray_Sphere_Tests,
  198.   Ray_Sphere_Tests_Succeeded,
  199.   Ray_Torus_Tests,
  200.   Ray_Torus_Tests_Succeeded,
  201.   Torus_Bound_Tests,
  202.   Torus_Bound_Tests_Succeeded,
  203.   Ray_CSG_Intersection_Tests,
  204.   Ray_CSG_Intersection_Tests_Succeeded,
  205.   Ray_CSG_Merge_Tests,
  206.   Ray_CSG_Merge_Tests_Succeeded,
  207.   Ray_CSG_Union_Tests,
  208.   Ray_CSG_Union_Tests_Succeeded,
  209.   Ray_Triangle_Tests,
  210.   Ray_Triangle_Tests_Succeeded,
  211.   Ray_TTF_Tests,
  212.   Ray_TTF_Tests_Succeeded,
  213.   Ray_Superellipsoid_Tests,
  214.   Ray_Superellipsoid_Tests_Succeeded,
  215.   Atmosphere_Samples,
  216.   Atmosphere_Supersamples,
  217.  
  218.   Reflected_Rays_Traced,
  219.   Refracted_Rays_Traced,
  220.   Transmitted_Rays_Traced,
  221.   Shadow_Cache_Hits,
  222.   Shadow_Rays_Succeeded,
  223.   Shadow_Ray_Tests,
  224.  
  225.   nChecked,
  226.   nEnqueued,
  227.   totalQueues,
  228.   totalQueueResets,
  229.   totalQueueResizes,
  230.   Polynomials_Tested,
  231.   Roots_Eliminated,
  232.   VBuffer_Tests,
  233.   VBuffer_Tests_Succeeded,
  234.   LBuffer_Tests,
  235.   LBuffer_Tests_Succeeded,
  236.  
  237.   Halo_Samples,
  238.   Halo_Supersamples,
  239.   Halo_Rays_Traced,
  240.  
  241. #if defined(MEM_STATS)
  242.   MemStat_Smallest_Alloc,
  243.   MemStat_Largest_Alloc,
  244.   MemStat_Largest_Mem_Usage,
  245. #if (MEM_STATS>=2)
  246.   MemStat_Total_Allocs,
  247.   MemStat_Total_Frees,
  248. #endif
  249. #endif
  250.  
  251.   /* Must be the last */
  252.   MaxStat
  253.  
  254. } Stats;
  255.  
  256.  
  257. typedef enum shelltype
  258.  {
  259.    PRE_SCENE_SHL = 0,
  260.    PRE_FRAME_SHL,
  261.    POST_FRAME_SHL,
  262.    POST_SCENE_SHL,
  263.    USER_ABORT_SHL,
  264.    FATAL_SHL,
  265.    MAX_SHL /* Must be last */
  266.  } SHELLTYPE;
  267.  
  268. typedef enum shellret
  269. {
  270.   IGNORE_RET = 0,
  271.   QUIT_RET,
  272.   USER_RET,
  273.   FATAL_RET,
  274.   SKIP_ONCE_RET,
  275.   ALL_SKIP_RET
  276. } SHELLRET;
  277.  
  278. typedef struct shelldata
  279.  {
  280.    SHELLRET Ret;
  281.    int Inverse;
  282.    char Command[POV_MAX_CMD_LENGTH];
  283.  } SHELLDATA;
  284.  
  285. typedef struct OPTIONS_STRUCT
  286. {
  287.   int File_Buffer_Size;
  288.   unsigned long Options;
  289.   char DisplayFormat;
  290.   char PaletteOption;
  291.  
  292.   char OutputFormat;
  293.   int OutputQuality;
  294.   char Input_File_Name[FILE_NAME_LENGTH];
  295.   char Output_File_Name[FILE_NAME_LENGTH];
  296.   char Output_Path[FILE_NAME_LENGTH];
  297.   char Output_Numbered_Name[FILE_NAME_LENGTH];
  298.   char Scene_Name[FILE_NAME_LENGTH];
  299.   DBL DisplayGamma;
  300.   DBL GammaFactor;
  301.  
  302.   unsigned long Quality_Flags;
  303.  
  304.   long AntialiasDepth;
  305.   DBL Antialias_Threshold;
  306.  
  307.   DBL JitterScale;
  308.  
  309.   int Abort_Test_Counter;
  310.  
  311.   char *Library_Paths[MAX_LIBRARIES];
  312.   int Library_Path_Index;
  313.  
  314.   int First_Column, Last_Column;
  315.   DBL First_Column_Percent, Last_Column_Percent;
  316.  
  317.   int First_Line, Last_Line;
  318.   DBL First_Line_Percent, Last_Line_Percent;
  319.  
  320.   /* Parse */
  321.   DBL Language_Version;
  322.  
  323.   unsigned Use_Slabs;
  324.   long BBox_Threshold;
  325.  
  326.   int Quality;
  327.  
  328.   int PreviewGridSize_Start;   /* Mosaic Preview - Initial pixel grid size */
  329.   int PreviewGridSize_End;     /* Mosaic Preview - Ending pixel grid size */
  330.  
  331.   FRAMESEQ FrameSeq;
  332.  
  333.   /* Should STREAM PATHS go somewhere here? */
  334.  
  335.   DBL Radiosity_Brightness;
  336.   long Radiosity_Count;
  337.   DBL Radiosity_Dist_Max;
  338.   DBL Radiosity_Error_Bound;
  339.   DBL Radiosity_Gray;  /* degree to which gathered light is grayed */
  340.   DBL Radiosity_Low_Error_Factor;
  341.   DBL Radiosity_Min_Reuse;
  342.   long Radiosity_Nearest_Count;
  343.   int Radiosity_Recursion_Limit;
  344.   long Radiosity_Quality;  /* Q-flag value for light gathering */
  345.   int Radiosity_File_ReadOnContinue;
  346.   int Radiosity_File_SaveWhileRendering;
  347.   int Radiosity_File_AlwaysReadAtStart;
  348.   int Radiosity_File_KeepOnAbort;
  349.   int Radiosity_File_KeepAlways;
  350.   int Radiosity_Preview_Done;  /* used in cache file processing */
  351.  
  352.  
  353.   int histogram_x, histogram_y, histogram_on;
  354.   Histogram_Types histogram_type;
  355.   char Histogram_File_Name[FILE_NAME_LENGTH];
  356.  
  357.   SHELLDATA *Shellouts;
  358.  
  359.   char Ini_Output_File_Name[FILE_NAME_LENGTH];
  360.  
  361.   int Tracing_Method;
  362.   int Do_Stats;
  363. } Opts;
  364.  
  365. /*****************************************************************************
  366. * Global variables
  367. ******************************************************************************/
  368. extern FRAME Frame;
  369.  
  370. extern COUNTER stats[MaxStat];
  371. extern COUNTER totalstats[MaxStat];
  372.  
  373. extern time_t tstart, tstop;
  374. extern DBL tparse, trender, tparse_total, trender_total;
  375.  
  376. extern char Color_Bits;
  377.  
  378. extern int Number_Of_Files;
  379. extern Opts opts;
  380.  
  381. extern FILE *stat_file;
  382. extern FILE_HANDLE *Output_File_Handle;
  383.  
  384.  
  385. extern int Help_Available;
  386.  
  387. extern int Abort_Test_Every;
  388. extern int Display_Started;
  389. extern int Stage;
  390. extern volatile int Stop_Flag;
  391. extern int pre_init_flag;
  392. extern int Experimental_Flag;
  393.  
  394. extern int Num_Echo_Lines, Echo_Line_Length;
  395. extern char *Option_String_Ptr;      
  396.  
  397. /*****************************************************************************
  398. * Global functions
  399. ******************************************************************************/
  400.  
  401. #ifdef NOCMDLINE
  402. # ifdef ALTMAIN
  403.   MAIN_RETURN_TYPE alt_main PARAMS((void));
  404. # else
  405.   MAIN_RETURN_TYPE main PARAMS((void));
  406. # endif
  407. #else
  408. # ifdef ALTMAIN
  409.   MAIN_RETURN_TYPE alt_main PARAMS((int argc, char ** argv));
  410. # else
  411.   MAIN_RETURN_TYPE main PARAMS((int argc, char ** argv));
  412. # endif
  413. #endif
  414.  
  415. int pov_stricmp PARAMS((char *s1,char *s2));
  416. void close_all PARAMS((void));
  417. void POV_Std_Split_Time PARAMS((DBL time_dif,unsigned long *hrs,unsigned long *mins,DBL *secs));
  418. FILE *Locate_File PARAMS((char *filename, char *mode, char *ext1, char *ext2, int err_flag));
  419.  
  420. SHELLRET pov_shellout PARAMS((SHELLTYPE Type));
  421. void pre_init_povray PARAMS((void));
  422.  
  423. void POV_Split_Path PARAMS((char *s, char *p, char *f));
  424.  
  425. #endif
  426.